#include <stdio.h>

int main( )
{
    int n, t, p = 0, i;
    bool l = false, s;
    while ( scanf("%d", &n) != EOF )
    {
        if ( n < 0 ) break;
        p++;
        if ( l ) printf("\n");
        else l = true;
        printf("Case %d.\n", p);
        s = false;
        for ( i = 2; n != 1; i++ )
        {
            if ( n % i == 0 )
            {
                t = 0;
                printf("%d ", i);
                while ( n % i == 0 )
                {
                    t++;
                    n /= i;
                }
                printf("%d ", t);
            }
        }
        printf("\n");
    }
    return 0;
}
